//
//  MyChartingCollectionViewCell.m
//  intelligent
//
//  Created by 甘世清 on 2024/3/3.
//

#import "MyChartingCollectionViewCell.h"

@implementation MyChartingCollectionViewCell
- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.layer.masksToBounds = YES;
        [self SQ_UIViewForSelfView];
    }
    return self;
}
/// 添加ui
-(void)SQ_UIViewForSelfView
{
    [self.contentView addSubview:self.bgimage];
    [self.bgimage mas_makeConstraints:^(MASConstraintMaker *make) {
         make.edges.equalTo(self.contentView);
    }];
    
    [self.contentView addSubview:self.rightBtn];
    [self.rightBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(40);
        make.top.right.equalTo(self.contentView);
    }];
}
- (void)setModel:(MyChartingModel *)model{
    _model = model;
    [self.bgimage sd_setImageWithURL:SQURLImage(model.url)];
     
           
    if (model.deleteFlag) {
        _rightBtn.image = SQGetImage(@"选中1");
    } else {
        _rightBtn.image = SQGetImage(@"未选中");
    }
}
- (SQCustomButton *)rightBtn {
    if (!_rightBtn) {
        _rightBtn = [[SQCustomButton alloc]initType:SQCustomButtonTopImageType imageSize:CGSizeMake(20, 20) midmargin:0];
        _rightBtn.image = SQGetImage(@"未选中");
    }
    return _rightBtn;
}
- (UIImageView *)bgimage{
    if (!_bgimage) {
        _bgimage = [[UIImageView alloc]init];
        _bgimage.contentMode = UIViewContentModeScaleAspectFill;
        _bgimage.clipsToBounds = YES;
        _bgimage.backgroundColor = SQColorF4F4F4;
        _bgimage.layer.cornerRadius = 8;
        _bgimage.layer.masksToBounds = YES;
    }
    return _bgimage;
}
@end
